import Vue from 'vue'
import Vuex from 'vuex'
import { getItem, setItem } from '@/utils/storage'

Vue.use(Vuex)

export default new Vuex.Store({
  // 仓库储存容器
  state: {
    // a.保存 用户token们
    user: getItem('1102token')
  },
  mutations: {
    // 1.将新的两个token保存到仓库user中
    setUserToken (state, userTokens) {
      // 1.1 保存到仓库
      state.user = userTokens
      console.log(userTokens)
      // 1.2 保存到本地localStorage
      setItem('1102token', userTokens)
    }
  },
  actions: {},
  modules: {}
})
